package com.stars.controller.system;

import com.stars.common.annotation.Log;
import com.stars.common.base.BaseConstant;
import com.stars.common.base.BaseMsg;
import com.stars.common.base.ResultMsg;
import com.stars.common.enums.OperationType;
import com.stars.controller.BaseController;
import com.stars.services.system.SysMenuUrlsConfigServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dj
 * @version V1.0
 * @Title: 菜单与url的关系表 mybatis dao
 * @date 2019-10-23 20:48:11
 */
@Slf4j
@RestController
@RequestMapping("/sysMenuUrlsCtl")
@Api(tags = "菜单与url的关系表")
public class SysMenuUrlsCtl extends BaseController {
    @Autowired
    private SysMenuUrlsConfigServices sysMenuUrlsConfigServicesImpl;
    /**
     * 保存
     *
     * @param menuId
     * @param urlIds
     * @return 成功失败
     * @throws Exception
     */
    @PostMapping(value = "/add")
    @ApiOperation(value = "菜单与url的关系表" + BaseMsg.MODULAR_ADD, notes = "菜单与url的关系表" + BaseMsg.MODULAR_ADD)
    @Log(detail = "菜单与url的关系表" + BaseMsg.MODULAR_ADD, operationType = OperationType.INSERT)
    public ResultMsg addSysMenuUrls(String menuId,String urlIds) throws Exception {
        return sysMenuUrlsConfigServicesImpl.add(menuId,urlIds.split(BaseConstant.SPOT));
    }
    /**
     * 删除
     *
     * @param menuId 菜单id
     * @param urlIds url 集合  33，323
     * @return 成功失败
     * @throws Exception
     */
    @PostMapping(value = "/delById")
    @ApiOperation(value = "菜单与url的关系表" + BaseMsg.MODULAR_DEL, notes = "菜单与url的关系表" + BaseMsg.MODULAR_DEL)
    @Log(detail = "菜单与url的关系表" + BaseMsg.MODULAR_DEL, operationType = OperationType.DELETE)
    public ResultMsg delSysMenuUrlsById(String menuId,String urlIds) throws Exception {
        sysMenuUrlsConfigServicesImpl.delByIdAndUrlId(menuId,urlIds.split(BaseConstant.SPOT));
        return ResultMsg.success();
    }


}